<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
<style type="text/css">
.ftitle{
    font-size:14px;
    font-weight:bold;
    padding:5px 0;
    margin-bottom:10px;
    border-bottom:1px solid #ccc;
}
.fitem{
    margin-bottom:10px;
}
.fitem label{
    display:inline-block;
    text-align:right;
    width: 19%;
}
</style>

<style type="text/css">
  .errorText
  {
      color:red;
  }
</style>
</head>
<body>
<form id="form1" method="post">
	<input id="e_id" name="id" class="mini-hidden" value="" />
	<div class="fitem">
		<label>仓库名称：</label>
		<input name="name" errorMode="none" onvalidation="checkValidation"  requiredErrorText="请输入仓库名称" vtype="maxLength:255" class="mini-textbox" required="true" style="width: 350px"/>
		<span id="name_error" class="errorText"></span>
	</div>
	<div class="fitem">
		<label>面积大小：</label>
		<input name="area"  errorMode="none" onvalidation="checkValidation"  requiredErrorText="请输入面积大小" class="mini-spinner" minValue="0" maxValue="999999" required="true" style="width: 150px"/>&nbsp;㎡
		<span id="area_error" class="errorText"></span>
	</div>
	<div class="fitem">
		<label>地址：</label>
		<input name="address" errorMode="none" onvalidation="checkValidation"  requiredErrorText="请输入地址"  class="mini-textbox" required="true" style="width: 350px"/>
		<span id="address_error" class="errorText"></span>
	</div>
</form>
<div style="text-align:center;padding:10px;">               
    <a class="mini-button" onclick="javascript:SaveData()" style="width:60px;margin-right:20px;">确定</a>       
    <a class="mini-button" onclick="javascript:window.CloseOwnerWindow();" style="width:60px;">取消</a>       
</div>
<script type="text/javascript">
mini.parse();
var form = new mini.Form("form1");
$("#e_id").val("");
//标准方法接口定义
function SetData(row) {
	//跨页面传递的数据对象，克隆后才可以安全使用
	row = mini.clone(row);
	form.setData(row);
	form.setChanged(false);
}

function SaveData() {
    var o = form.getData(); 
    form.validate();
    if (form.isValid() == false) return;
    $.ajax({
        url: "warehouse_edit_save.do",
		type: 'post',
		dataType: 'json',
        data: o,
        cache: false,
        success: function (text) {
            if(text.success){
            	window.CloseOwnerWindow("succ");
            }else{
            	mini.alert("数据错误！");
            }
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert(jqXHR.responseText);
            window.CloseOwnerWindow();
        }
    });
}

//验证编码
function onEnglishAndNumberValidation(e) {
	 var id =e.sender.name + "_error";
     var el = document.getElementById(id);
     checkValidation(e);
    if (e.isValid) {
        if (isEnglishAndNumber(e.value) == false) {
            e.errorText = "必须输入英文+数字";
            el.innerHTML =e.errorText;
            e.isValid = false;
        }
    }
}

function isEnglishAndNumber(v) {
    var re = new RegExp("^[0-9a-zA-Z\_]+$");
    if (re.test(v)) return true;
    return false;
}

function updateError(e) {
    var id =e.sender.name + "_error";
    var el = document.getElementById(id);
    if (el) {
        el.innerHTML =e.errorText;
    }
}

function checkValidation(e) {                  
    updateError(e);
}
</script>
</body>
</html>